<?php
namespace app\admin\controller\setting;
use app\admin\controller\Controller;
use app\common\model\Setting as SettingModel;

class Setting extends Controller
{

    // 统一调用接口
    public function setting(){
        return $this->renderSuccess($this->getEvent($this->request->param('name')));
    }

    // 获取设置信息接口
    private function getEvent($key){
        $model = new SettingModel;
        return $model->getItem($key);
    }

    /**
     * 更新设置事件
     * @param $key
     * @param $vars
     * @return array|mixed
     * @throws \think\exception\DbException
     */
    private function updateEvent($key, $vars = [])
    {
        $model = new SettingModel;
        if ($model->edit($key, $this->request->param($key))) {
            return $this->renderSuccess('操作成功');
        }
        return $this->renderError($model->getError() ?? '操作失败');
    }

}